home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Libraries / VideoToolbox 97.08.16 / (Utilities) / Quick3 / Quick3.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-07  |  2.1 KB  |  64 lines  |  [TEXT/CWIE]

  1. /* Quick3.h
  2. HISTORY:
  3. 3/10/92 dgp    Cast PARAMS to be a short int.
  4.             If appropriate, use the 68881 log and exp instructions for speed.
  5.             For speed, defined exp10(), and use exp and log to compute pow.
  6.             These changes speed up the computation enormously, perhaps 50-fold,
  7.             yet when run on "sample.data" the resulting "sample.fit" is unchanged.
  8. 5/27/95 dgp replaced #include <math.h> by #include "VideoToolbox.h", since I routinely
  9.             compile everything with the VideoToolbox precompiled header, which
  10.             normally included fp.h instead of math.h.
  11. 2/7/97    nm    increased MAX_CONTRASTS from 200 to 1000.
  12. */
  13. #pragma once    /* prevent multiple inclusions of this file */
  14. #include "VideoToolbox.h"
  15. #if !defined(_STDIO)
  16.     #include <stdio.h>
  17. #endif
  18. #if !defined(_STDLIB)
  19.     #include <stdlib.h>
  20. #endif
  21. #define MAX_CONTRASTS 1000
  22. #define ILLEGAL_PARAMETERS -1.0    /* unique value indicating parameters out of bounds */
  23. #define MACINTOSH 1
  24. #ifndef exp10
  25.     #define exp10(x) exp(LOG10*(x))            /* faster than pow(10.0,x) */
  26. #endif
  27. #undef pow
  28. #define pow(x,y) exp(log(x)*(y))            /* faster by use of 68881 instructions */
  29. #if !defined(LOG10)
  30.     #define LOG10    2.30258509299404568402    /* computed in Mathematica */
  31. #endif
  32.  
  33. typedef struct {
  34.     double contrast;
  35.     long trials;
  36.     long correct;
  37. } contrastRecord;
  38.  
  39. typedef struct {
  40.     long contrasts;
  41.     contrastRecord c[MAX_CONTRASTS];    /* an array of records is easier to sort */
  42. } dataRecord;
  43.  
  44. typedef struct {
  45.     double logAlpha;
  46.     double beta;
  47.     double gamma;
  48.     double delta;
  49. } paramRecord;
  50.  
  51. #define PARAMS ((short)(sizeof(paramRecord)/sizeof(double)))
  52.  
  53. typedef double (*PsychometricFunctionPtr)(double contrast,paramRecord *paramPtr);
  54.  
  55. double Weibull(double contrast,paramRecord *paramPtr);
  56. double LogLikelihood(dataRecord *data,paramRecord *params,
  57.     PsychometricFunctionPtr PsychFun);
  58. double PsychometricFit(paramRecord *paramPtr
  59.     ,PsychometricFunctionPtr PsychFun
  60.     ,dataRecord *dataPtr,double *logLikelihoodPtr,int degreesOfFreedom
  61.     ,double *chiSquarePtr,int *chiSquareDFPtr);
  62. void MonotonicFit(dataRecord *data,double *logLikelihoodPtr,int *degreesOfFreedomPtr);
  63. void SortAndMergeContrasts(dataRecord *dataPtr);
  64.